﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CodeToolBox.Form
{
    public partial class UIFlowItem : UIUserControl
    {
        /// <summary>
        /// 功能描述
        /// </summary>
        [Description("功能描述"), Category("自定义属性")]
        public string descstr { get; set; }= "暂无介绍!";
        [Description("功能名称"), Category("自定义属性")]
        public string objectName { get; set; }

        [Description("功能图片"), Category("自定义属性")]
        public Bitmap picimage { get; set; }


        public event EventHandler CustomControlClicked;
        public UIFlowItem()
        {   
            InitializeComponent();           
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            //background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
            // 定义两种颜色
            Color color1 = ColorTranslator.FromHtml("#a1c4fd"); // 第一种颜色
            Color color2 = ColorTranslator.FromHtml("#c2e9fb"); // 第二种颜色

            // 创建LinearGradientBrush对象
            LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle, color1, color2, LinearGradientMode.Vertical);

            // 使用Graphics对象填充矩形区域
            e.Graphics.FillRectangle(brush, this.ClientRectangle);
        }

        private void pictureBox1_MouseHover(object sender, EventArgs e)
        {
            // 创建一个新的ToolTip对象
            ToolTip toolTip = new ToolTip();
            toolTip.IsBalloon = true;
            // 设置要显示的提示文本
            toolTip.SetToolTip(pictureBox1, descstr);
        }

        private void UIFlowItem_Load(object sender, EventArgs e)
        {
            pictureBox1.Image = picimage;
            label1.Text = objectName;
        }

        public void UIFlowItem_Click(object sender, EventArgs e)
        {
            CustomControlClicked?.Invoke(this, EventArgs.Empty);
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
